<%@ page import="java.util.ArrayList" %>
<%@ page import="entity.Student811" %><%--
  Created by IntelliJ IDEA.
  User: wang'ze'liang
  Date: 2021/8/11
  Time: 16:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/bootstrap-3.4.1-dist/css/bootstrap.css" />

</head>
<body>

    <table class="table table-striped table-hover">
        <tr>
            <td>ID</td>
            <td>姓名</td>
            <td>年龄</td>
            <td>性别</td>
            <td>删除/修改</td>
        </tr>
        <%
            ArrayList<Student811> arrayList = (ArrayList<Student811>) request.getAttribute("st811");
            for(Student811 st811 : arrayList){
        %>
        <tr>
            <td><%=st811.getId()%></td>
            <td><%=st811.getName()%></td>
            <td><%=st811.getAge()%></td>
            <td><%=st811.getGender()%></td>
<%--
            <td><a href="<%=request.getContextPath()%>/student811?st=deleteById&id=<%=st811.getId()%>">删除</a> </td>
--%>
            <td>
                <a href="javascript:void(0) " class="btn btn-warning btn-sm" onclick="deleteById(<%=st811.getId()%>)">删除</a>
                <a href="<%=request.getContextPath()%>/student811?st=selectById&id=<%=st811.getId()%> " class="btn btn-success btn-sm" >修改</a>
            </td>
        </tr>
        <%
            }
        %>
    </table>
    <a class="btn btn-success" href="<%=request.getContextPath()%>/insert_student811.jsp">添加</a>


    <script type="text/javascript">
        function deleteById(id){
            var isDelete = confirm("你确认要删除吗？");
            if (isDelete) {
                location.href = "<%=request.getContextPath()%>/student811?st=deleteById&id=" + id;
            }

        }


    </script>

</body>
</html>
